package com.ruibang.glass.produce.controller.tr;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.produce.domain.req.PackagingRecordsReq;
import com.ruibang.glass.produce.domain.req.TrRecordReq;
import com.ruibang.glass.produce.domain.resp.TrProductionRecord;
import com.ruibang.glass.produce.service.ProductionRecordService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @Author: songJinKang
 * @CreateTime: 2023-11-29  13:56
 * @Description: TODO
 * @Version: 1.0
 */

@Api(tags = "投入生产记录控制器")
@RestController
@RequestMapping("/api/glass/produce/tr/productionRecord")
public class ProductionRecordController {

    @Autowired
    private ProductionRecordService productionRecordService;

    @PostMapping("/getCurrentTimeTrRecord")
    @ApiOperation(value = "当前冷端生产情况汇报", response = ResultBody.class)
    public ResultBody getCurrentTimeTrRecord() {
        return productionRecordService.getCurrentTimeTrRecord();
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "查询投入生产记录", response = ResultBody.class)
    public ResultBody<IPage<TrProductionRecord>> pageQuery(@RequestBody TrRecordReq trRecordReq) {
        return ResultBody.success(productionRecordService.pageQuery(trRecordReq));
    }

    @PostMapping("/export")
    @ApiOperation(value = "数据导出", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 3, target = FrequencyControl.Target.IP)
    public void export(@RequestBody TrRecordReq trRecordReq, HttpServletResponse response) {
        productionRecordService.export(trRecordReq, response);
    }
}
